import { loadPlugin, loadPluginFn } from '../../app/config/loadplugin.config.js';
import authService from '../../app/resolves/authService.js';
import getCourseList from '../resolves/getCourseList.js';
import getCourseDetail from '../resolves/getCourseDetail.js';
import getCpList from '../../cp/resolves/getCpList.js';
import getCpListTiming from '../../cp/resolves/getCpListTiming.js';
import getRaceDetail from '../../race/resolves/getRaceDetail.js';

import courseHtml from 'ngtemplate!html!../../../tpls/course/course.html';
import courseListHtml from 'ngtemplate!html!../../../tpls/course/course.list.html';


/**
 * CourseRouter - config
 * 赛事模块路由设置
 */
CourseRouter.$inject = ['$stateProvider', '$urlRouterProvider', '$httpProvider', '$locationProvider', '$ocLazyLoadProvider'];
function CourseRouter($stateProvider, $urlRouterProvider, $httpProvider, $locationProvider, $ocLazyLoadProvider) {

	//set router
    $stateProvider

		// 新建科目
		.state('dashboard.race.course', {
		    url: '/course',
		    data: { 
		        pageTitle: '新建科目' 
		    },
		    templateUrl: courseHtml,
		    controller: 'CourseController as vm',
		    resolve: {
		    	authService: authService,
		    	getCpList: getCpList,
		    	getRaceDetail: getRaceDetail,
		    	loadPlugin: loadPluginFn([loadPlugin.locale, loadPlugin.moment, loadPlugin.icheck, loadPlugin.blink])
            }
		})

		// 科目列表
		.state('dashboard.race.courselist', {
		    url: '/course/list',
		    data: { 
		        pageTitle: '科目列表' 
		    },
		    templateUrl: courseListHtml,
		    controller: 'CourseListController as vm',
		    resolve: {
		    	authService: authService,
		    	getCourseList: getCourseList,
                loadPlugin: loadPluginFn(loadPlugin.dataTables)
            }
		})

		// 编辑科目
		.state('dashboard.race.courseedit', {
		    url: '/course/edit?course_id&type',
		    data: { 
		        pageTitle: '编辑科目' 
		    },
		    templateUrl: courseHtml,
		    controller: 'CourseEditController as vm',
		    resolve: {
		    	authService: authService,
		    	getCourseDetail: getCourseDetail,
		    	getCpList: getCpList,
		    	getCpListTiming: getCpListTiming,
		    	getRaceDetail: getRaceDetail,
                loadPlugin: loadPluginFn([loadPlugin.locale, loadPlugin.moment, loadPlugin.icheck, loadPlugin.blink])
            }
		});

}

export default CourseRouter; 